#include <stdio.h>

void printArray(int value[], int count)
{
	for(int i=0; i<count; i++)
	{
		printf("%d ", value[i]);
	}
	printf("\n");
}
void slectionSort(int value[], int count)
{
	int min=0;
	int dex=0;

	for(int i=0; i<count-1; i++)
	{
		dex=i;
		min = value[i];
		for(int j=i+1;j<count;j++)
		{
			if( min > value[j] )
			{
				min = value[j];
				dex=j;
			}
		}
		value[dex] = value[i];
		value[i] = min;
		printf("Step-%d, ",i+1);
		for(int j = 0; j<count; j++)
		{
			printf("%d ", value[j]);
		}
		printf("\n");
	}
}
int main(int argc, char *argv[])
{
	int values[] = {80, 50, 70, 10, 60, 20, 40, 30};

	printf("Before Sort\n");
	printArray(values, 8);

	slectionSort(values, 8);

	printf("\nAfter Sort\n");
	printArray(values, 8);

	return 0;

}